# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=git-interactive-rebase-tool
pkgver=2.4.1
pkgrel=0
pkgdesc="Terminal based sequence editor for interactive rebase"
url="https://gitrebasetool.mitmaro.ca"
arch="all"
license="GPL-3.0-or-later"
makedepends="cargo libgit2-dev zlib-dev cargo-auditable"
subpackages="$pkgname-doc"
source="https://github.com/MitMaro/git-interactive-rebase-tool/archive/$pkgver/git-interactive-rebase-tool-$pkgver.tar.gz
	0002-cargo-update.patch"
options="net"

export CARGO_PROFILE_RELEASE_OPT_LEVEL="z"

prepare() {
	default_prepare

	# Rust target triple.
	local target=$(rustc -vV | sed -n 's/host: //p')

	# Build against system-provided libs
	mkdir -p .cargo
	cat >> .cargo/config.toml <<-EOF
		[target.$target]
		git2 = { rustc-link-lib = ["git2"] }
	EOF

	cargo fetch --target="$CTARGET" --locked
}

build() {
	cargo auditable build --frozen --release
}

check() {
	# test in src/version.rs need environments
	export GIRT_BUILD_GIT_HASH="" GIRT_BUILD_DATE=""
	cargo test --frozen
}

package() {
	install -D -m755 target/release/interactive-rebase-tool -t "$pkgdir"/usr/bin/

	install -D -m 644 src/interactive-rebase-tool.1 \
		"$pkgdir"/usr/share/man/man1/interactive-rebase-tool.1
}

sha512sums="
3ad021e5089db9824b41f99f3569f68307ebc223c458be41d104b2b09691a027cd299cce0d256aec08720e03114a5b6e41a3110413b845e363b38142d02a9ef6  git-interactive-rebase-tool-2.4.1.tar.gz
9171e4d1356fd1ddb919ff0677d4b61801ee710859c7e5b68d69cdd43c7d04ebc348461360c94dc33dfa2831778077e1626c5890d9e331857124a983b4caef39  0002-cargo-update.patch
"
